package com.sunreal.paygateway.common;

import java.util.HashMap;
import java.util.Map;

import com.alibaba.fastjson.JSONObject;
import com.google.gson.ExclusionStrategy;
import com.google.gson.FieldAttributes;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.sunreal.paygateway.dao.vo.SunrealPayOrder;
import com.sunreal.paygateway.sys.util.GsonUtil;
import com.sunreal.paygateway.sys.util.PayDigestUtil;
import com.sunreal.paygateway.sys.util.result.RetResult;
import com.sunreal.paygateway.sys.util.result.WebResult;

/**
 * 功能描述：//TODO
 *
 * @Author 彭广
 * @Date 2019/4/16
 */
public class test {

    public static void main(String[] args) throws IllegalAccessException {
//        sign();
        test2();
    }

    private static void test2() throws IllegalAccessException {
        RetResult result = new RetResult();
        result.setMsg("调用成功！");
        result.setData("112019041811444300000");
        result.setErrorCode(0);
        result.setSuccess(true);
        System.out.println(PayDigestUtil.getSign(result, "987654321"));

    }
    private static void sign() throws IllegalAccessException {
        SunrealPayOrder order = new SunrealPayOrder();
        order.setMchid("1");
        //        order.setMchorderno("112432134222");
        //        order.setAmount(1L);
        //        order.setChannelid("WX_NATIVE");
        //        order.setCurrency("CNY");
        //        order.setNotifyurl("http://192.168.100.24:8080/newframe/api/payorder/testPayResult.html");
        //        order.setReturnurl("http://192.168.100.24:8080/newframe");
        //        order.setSubject("微信支付测试订单名称");
        //        order.setBody("微信支付测试商品描述");
        //        order.setOriginalorderid("112432134222");

        //        order.setUpdatetime(1555450099000L);
        //        order.setCreatetime(1555450099000L);
        //        order.setNotifycount(0L);
        //        order.setStatus(0L);
        JSONObject info = new JSONObject();
        info.put("productid", "9");
        //        order.setExtra(info.toJSONString());
        System.out.println(PayDigestUtil.getSign(order, "123456789"));
        Gson gson = new GsonBuilder().create();
        System.out.println(GsonUtil.toJson(order));
        //
        //        Map<String,Object> map = new HashMap<>();
        //        map.put("result","{\"amount\":1,\"payOrderId\":\"P0020190416162821000000\",\"mchId\":\"1\",\"mchOrderNo\":\"123\",\"subject\":\"微信支付测试订单名称\",\"updateTime\":1555450099000,\"body\":\"微信支付测试商品描述\",\"channelMchId\":\"1520514741\",\"notifyCount\":0,\"originalOrderId\":\"123123333\",\"createTime\":1555450099000,\"extra\":\"{\\\"productId\\\":\\\"9\\\"}\",\"notifyUrl\":\"http://192.168.100.24:8080/newframe/api/payorder/testPayResult.html\",\"currency\":\"CNY\",\"returnUrl\":\"http://192.168.100.24:8080/newframe\",\"channelId\":\"WX_NATIVE\",\"status\":0}");
        //        map.put("resCode","SUCCESS");
        //        map.put("retCode","SUCCESS");
        //        map.put("retMsg","");
        //        System.out.println(PayDigestUtil.getSign(map, "987654321"));
    }


}
